﻿//Instances
var totalInstancesUsed = parseInt(localStorage.getItem('totalInstancesUsed'));
var maxTotalInstances = parseInt(localStorage.getItem('maxTotalInstances'));
//VCPUs
var totalCoresUsed = parseInt(localStorage.getItem('totalCoresUsed'));
var maxTotalCores = parseInt(localStorage.getItem('maxTotalCores'));
//RAM
var totalRAMUsed = parseInt(localStorage.getItem('totalRAMUsed'));
var maxTotalRAMSize = parseInt(localStorage.getItem('maxTotalRAMSize'));
//Floating_IPs
var totalFloatingIpsUsed = parseInt(localStorage.getItem('totalFloatingIpsUsed'));
var maxTotalFloatingIps = parseInt(localStorage.getItem('maxTotalFloatingIps'));
//Security_Groups
var totalSecurityGroupsUsed = parseInt(localStorage.getItem('totalSecurityGroupsUsed'));
var maxSecurityGroups = parseInt(localStorage.getItem('maxSecurityGroups'));
//Volumes
var totalVolumesUsed = parseInt(localStorage.getItem('totalVolumesUsed'));
var maxTotalVolumes = parseInt(localStorage.getItem('maxTotalVolumes'));
//Volume_Storage
var totalGigabytesUsed = parseInt(localStorage.getItem('totalGigabytesUsed'));
var maxTotalVolumeGigabytes = parseInt(localStorage.getItem('maxTotalVolumeGigabytes'));			
	
$(document).ready(function(){

	$('#Instances_Used').text('totalInstancesUsed：' + totalInstancesUsed);
	$('#Instances_Max').text('maxTotalInstances：' + maxTotalInstances);
	
	$('#VCPUs_Used').text('totalCoresUsed：' + totalCoresUsed);
	$('#VCPUs_Max').text('maxTotalCores：' + maxTotalCores);

	$('#RAM_Used').text('totalRAMUsed：' + totalRAMUsed);
	$('#RAM_Max').text('maxTotalRAMSize：' + maxTotalRAMSize);

	$('#Floating_IPs_Used').text('totalFloatingIpsUsed：' + totalFloatingIpsUsed);
	$('#Floating_IPs_Max').text('maxTotalFloatingIps：' + maxTotalFloatingIps);

	$('#Security_Groups_Used').text('totalSecurityGroupsUsed：' + totalSecurityGroupsUsed);
	$('#Security_Groups_Max').text('maxSecurityGroups：' + maxSecurityGroups);

	$('#Volumes_Used').text('totalVolumesUsed：' + totalVolumesUsed);
	$('#Volumes_Max').text('maxTotalVolumes：' + maxTotalVolumes);

	$('#Volume_Storage_Used').text('totalGigabytesUsed：' + totalGigabytesUsed);
	$('#Volume_Storage_Max').text('maxTotalVolumeGigabytes：' + maxTotalVolumeGigabytes);	
});

var app = angular.module("nvd3TestApp", ['nvd3ChartDirectives']);

function Instances($scope) {
	$scope.InstancesData = [{
		key: "One",
		y: totalInstancesUsed
	}, {
		key: "Two",
		y: (maxTotalInstances - totalInstancesUsed)
	}];
		
	$scope.width = 300;
	$scope.height = 300;
	$scope.xFunction = function() {
		return function(d) {
			return d.key;
		};
	}
	$scope.yFunction = function() {
		return function(d) {
			return d.y;
		};
	}
	$scope.descriptionFunction = function() {
		return function(d) {
			return d.key;
		}
	}
}

function VCPUs($scope) {
	$scope.VCPUsData = [{
		key: "One",
		y: totalCoresUsed
	}, {
		key: "Two",
		y: (maxTotalCores - totalCoresUsed)
	}];

	$scope.width = 300;
	$scope.height = 300;
	$scope.xFunction = function() {
		return function(d) {
			return d.key;
		};
	}
	$scope.yFunction = function() {
		return function(d) {
			return d.y;
		};
	}
	$scope.descriptionFunction = function() {
		return function(d) {
			return d.key;
		}
	}
}

function RAM($scope) {
	$scope.RAMData = [{
		key: "One",
		y: totalRAMUsed
	}, {
		key: "Two",
		y: (maxTotalRAMSize - totalRAMUsed)
	}];

	$scope.width = 300;
	$scope.height = 300;
	$scope.xFunction = function() {
		return function(d) {
			return d.key;
		};
	}
	$scope.yFunction = function() {
		return function(d) {
			return d.y;
		};
	}
	$scope.descriptionFunction = function() {
		return function(d) {
			return d.key;
		}
	}
}

function Floating_IPs($scope) {
	$scope.Floating_IPsData = [{
		key: "One",
		y: totalFloatingIpsUsed
	}, {
		key: "Two",
		y: (maxTotalFloatingIps - totalFloatingIpsUsed)
	}];

	$scope.width = 300;
	$scope.height = 300;
	$scope.xFunction = function() {
		return function(d) {
			return d.key;
		};
	}
	$scope.yFunction = function() {
		return function(d) {
			return d.y;
		};
	}
	$scope.descriptionFunction = function() {
		return function(d) {
			return d.key;
		}
	}
}

function Security_Groups($scope) {
	$scope.Security_GroupsData = [{
		key: "One",
		y: totalSecurityGroupsUsed
	}, {
		key: "Two",
		y: (maxSecurityGroups - totalSecurityGroupsUsed)
	}];

	$scope.width = 300;
	$scope.height = 300;
	$scope.xFunction = function() {
		return function(d) {
			return d.key;
		};
	}
	$scope.yFunction = function() {
		return function(d) {
			return d.y;
		};
	}
	$scope.descriptionFunction = function() {
		return function(d) {
			return d.key;
		}
	}
}

function Volumes($scope) {
	$scope.VolumesData = [{
		key: "One",
		y: totalVolumesUsed
	}, {
		key: "Two",
		y: (maxTotalVolumes - totalVolumesUsed)
	}];

	$scope.width = 300;
	$scope.height = 300;
	$scope.xFunction = function() {
		return function(d) {
			return d.key;
		};
	}
	$scope.yFunction = function() {
		return function(d) {
			return d.y;
		};
	}
	$scope.descriptionFunction = function() {
		return function(d) {
			return d.key;
		}
	}
}

function Volume_Storage($scope) {
	$scope.Volume_StorageData = [{
		key: "One",
		y: totalGigabytesUsed
	}, {
		key: "Two",
		y: (maxTotalVolumeGigabytes - totalGigabytesUsed)
	}];

	$scope.width = 300;
	$scope.height = 300;
	$scope.xFunction = function() {
		return function(d) {
			return d.key;
		};
	}
	$scope.yFunction = function() {
		return function(d) {
			return d.y;
		};
	}
	$scope.descriptionFunction = function() {
		return function(d) {
			return d.key;
		}
	}
}
